home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CONTAS2.PAK / CONTAIN.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  168 lines

  1. // Contain.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Contain.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "ChildFrm.h"
  9. #include "ContrDoc.h"
  10. #include "ContrVw.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CContainerApp
  20.  
  21. BEGIN_MESSAGE_MAP(CContainerApp, CWinApp)
  22.     //{{AFX_MSG_MAP(CContainerApp)
  23.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  24.         // NOTE - the ClassWizard will add and remove mapping macros here.
  25.         //    DO NOT EDIT what you see in these blocks of generated code!
  26.     //}}AFX_MSG_MAP
  27.     // Standard file based document commands
  28.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  29.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  30.     // Standard print setup command
  31.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CContainerApp construction
  36.  
  37. CContainerApp::CContainerApp()
  38. {
  39.     // TODO: add construction code here,
  40.     // Place all significant initialization in InitInstance
  41. }
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // The one and only CContainerApp object
  45.  
  46. CContainerApp theApp;
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CContainerApp initialization
  50.  
  51. BOOL CContainerApp::InitInstance()
  52. {
  53.     // Initialize OLE libraries
  54.     if (!AfxOleInit())
  55.     {
  56.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  57.         return FALSE;
  58.     }
  59.  
  60.     // Standard initialization
  61.     // If you are not using these features and wish to reduce the size
  62.     //  of your final executable, you should remove from the following
  63.     //  the specific initialization routines you do not need.
  64.  
  65. #ifdef _AFXDLL
  66.     Enable3dControls();                     // Call this when using MFC in a shared DLL
  67. #else
  68.     Enable3dControlsStatic();       // Call this when linking to MFC statically
  69. #endif
  70.  
  71.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  72.  
  73.     // Register the application's document templates.  Document templates
  74.     //  serve as the connection between documents, frame windows and views.
  75.  
  76.     CMultiDocTemplate* pDocTemplate;
  77.     pDocTemplate = new CMultiDocTemplate(
  78.         IDR_CONTRTYPE,
  79.         RUNTIME_CLASS(CContainerDoc),
  80.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  81.         RUNTIME_CLASS(CContainerView));
  82.     pDocTemplate->SetContainerInfo(IDR_CONTRTYPE_CNTR_IP);
  83.     AddDocTemplate(pDocTemplate);
  84.  
  85.     // create main MDI Frame window
  86.     CMainFrame* pMainFrame = new CMainFrame;
  87.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  88.         return FALSE;
  89.     m_pMainWnd = pMainFrame;
  90.  
  91.     // Enable drag/drop open
  92.     m_pMainWnd->DragAcceptFiles();
  93.  
  94.     // Enable DDE Execute open
  95.     EnableShellOpen();
  96.     RegisterShellFileTypes(TRUE);
  97.  
  98.     // Parse command line for standard shell commands, DDE, file open
  99.     CCommandLineInfo cmdInfo;
  100.     ParseCommandLine(cmdInfo);
  101.  
  102.     // Dispatch commands specified on the command line
  103.     if (!ProcessShellCommand(cmdInfo))
  104.         return FALSE;
  105.  
  106.     // The main window has been initialized, so show and update it.
  107.     pMainFrame->ShowWindow(m_nCmdShow);
  108.     pMainFrame->UpdateWindow();
  109.  
  110.     return TRUE;
  111. }
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CAboutDlg dialog used for App About
  115.  
  116. class CAboutDlg : public CDialog
  117. {
  118. public:
  119.     CAboutDlg();
  120.  
  121. // Dialog Data
  122.     //{{AFX_DATA(CAboutDlg)
  123.     enum { IDD = IDD_ABOUTBOX };
  124.     //}}AFX_DATA
  125.  
  126.     // ClassWizard generated virtual function overrides
  127.     //{{AFX_VIRTUAL(CAboutDlg)
  128.     protected:
  129.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  130.     //}}AFX_VIRTUAL
  131.  
  132. // Implementation
  133. protected:
  134.     //{{AFX_MSG(CAboutDlg)
  135.         // No message handlers
  136.     //}}AFX_MSG
  137.     DECLARE_MESSAGE_MAP()
  138. };
  139.  
  140. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  141. {
  142.     //{{AFX_DATA_INIT(CAboutDlg)
  143.     //}}AFX_DATA_INIT
  144. }
  145.  
  146. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  147. {
  148.     CDialog::DoDataExchange(pDX);
  149.     //{{AFX_DATA_MAP(CAboutDlg)
  150.     //}}AFX_DATA_MAP
  151. }
  152.  
  153. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  154.     //{{AFX_MSG_MAP(CAboutDlg)
  155.         // No message handlers
  156.     //}}AFX_MSG_MAP
  157. END_MESSAGE_MAP()
  158.  
  159. // App command to run the dialog
  160. void CContainerApp::OnAppAbout()
  161. {
  162.     CAboutDlg aboutDlg;
  163.     aboutDlg.DoModal();
  164. }
  165.  
  166. /////////////////////////////////////////////////////////////////////////////
  167. // CContainerApp commands
  168.